using ImageCSharp.Core.Interfaces;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows;

namespace ImageCSharp.Controls
{
    /// <summary>
    /// 统计信息面板控件
    /// </summary>
    public partial class StatisticsPanel : UserControl, INotifyPropertyChanged
    {
        #region Dependency Properties

        public static readonly DependencyProperty StatisticsProperty =
            DependencyProperty.Register("Statistics", typeof(ImageStatistics), typeof(StatisticsPanel),
                new PropertyMetadata(null, OnStatisticsChanged));

        public ImageStatistics Statistics
        {
            get => (ImageStatistics)GetValue(StatisticsProperty);
            set => SetValue(StatisticsProperty, value);
        }

        #endregion

        public StatisticsPanel()
        {
            InitializeComponent();
            DataContext = this;
        }

        private static void OnStatisticsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is StatisticsPanel panel)
            {
                panel.OnPropertyChanged(nameof(Statistics));
                //panel.OnPropertyChanged(nameof(ImageSize));
                //panel.OnPropertyChanged(nameof(ImageFormat));
                //panel.OnPropertyChanged(nameof(FileSize));
                //panel.OnPropertyChanged(nameof(MouseColor));
                //panel.OnPropertyChanged(nameof(MouseRGB));
                //panel.OnPropertyChanged(nameof(MouseHex));
            }
        }

        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler? PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}